package com.tbit.uqbike.webmanager.dto;

import com.tbit.common.constant.OperationPlatform;
import com.tbit.uqbike.annos.Excel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 车辆操作日志
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MachineOpLogDTO implements Serializable {
    private static final long serialVersionUID = -4536617849567731586L;
    /**
     * 车辆编号
     */
    @Excel(name = "车辆编号", sort = 0)
    private String userCode;
    /**
     * 设备编号
     */
    @Excel(name = "设备编号", sort = 1)
    private String machineNO;
    /**
     * 操作内容
     */
    @Excel(name = "操作内容", sort = 2)
    private String operation;
    /**
     * 操作类型
     */
    @Excel(name = "操作类型", sort = 3)
    private String opType;
    /**
     * 操作人
     */
    @Excel(name = "操作人", sort = 4)
    private String opUser;
    /**
     * 操作人手机号
     */
    private String opUserPhone;
    /**
     * 操作平台 1-用户端 2-管理端 3-运维端
     *
     * @see OperationPlatform
     */
    @Excel(name = "操作平台", sort = 5,readConverterExp = "1=小程序客户端,2=管理平台,3=运维APP")
    private Integer opPlatform;
    /**
     * 操作结果
     */
    @Excel(name = "操作结果", sort = 6,readConverterExp = "true=成功,false=失败")
    private Boolean result;
    /**
     * 操作时间
     */
    @Excel(name = "操作平台", sort = 7,dateFormat = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime opTime;
    /**
     * 详情
     */
    @Excel(name = "详情", sort = 8)
    private String detail;

    public String getOpUser() {
        if (StringUtils.isNotBlank(opUserPhone)){
            opUser = opUser + "(" + opUserPhone + ")";
        }
        return opUser;
    }
}
